package qsc.algorithm.primAlgorithm;

import java.util.Arrays;

/**
 * @auther QiuShangcheng
 * @create 2021/4/21
 */
public class MGraph {
    private int verxs;//节点个数
    private char[] data;//节点数据
    private int[][] weight;//邻边矩阵
    private boolean[] visited;//记录已访问的节点

    public boolean[] getVisited() {
        return visited;
    }

    public MGraph setVisited(boolean[] visited) {
        this.visited = visited;
        return this;
    }

    public MGraph(int verxs, char[] data, int[][] weight) {
        this.verxs = verxs;
        this.data = data;
        this.weight = weight;
        this.visited = new boolean[verxs];
    }

    //初始化图大小
    public MGraph(int n) {
        this.verxs = n;
        this.data = new char[n];
        this.weight = new int[n][n];
    }

    //初始化图的节点数据和邻接矩阵
    public void createGraph(char[] data, int[][] weight) {
        for (int i = 0; i < this.verxs; i++) {

            this.data[i] = data[i];
            for (int j = 0; j < this.verxs; j++) {

                this.weight[i][j] = weight[i][j];
            }
        }
    }

    //显示初始化后图的邻接矩阵
    public void showMGraph(){
        for (int[] link : this.weight) {
            System.out.println(Arrays.toString(link));
        }
    }

    public int getVerxs() {
        return verxs;
    }

    public MGraph setVerxs(int verxs) {
        this.verxs = verxs;
        return this;
    }

    public char[] getData() {
        return data;
    }

    public MGraph setData(char[] data) {
        this.data = data;
        return this;
    }

    public int[][] getWeight() {
        return weight;
    }

    public MGraph setWeight(int[][] weight) {
        this.weight = weight;
        return this;
    }
}
